document.writeln('<script type="text/javascript" src="../.././static/js/public-head.js"></script>');
function echartsLine(prefix){
    this.prefix = prefix;
    echartsLine.prototype.init = function(){
        var t_prefix = this.prefix;
        layui.config({
            base: basePath+'/layui/lay/modules/'
        }).extend({
            //formSelects: 'formSelects-v4'
        }).use([ 'form', 'code', 'colorpicker', 'element' ], function() {
            var $ = layui.$;
            var form = layui.form;

            form.render();

            /*---给表单控件添加name属性，并绑定事件----*/
            $(".dynamic-series").each(function(i,e){
                var ele = $(e),tagName = ele.context.tagName,type = ele.context.type,tempString = ele.attr("dynamicSeries"),tempName = t_prefix + tempString;
                if(tagName.toUpperCase()=="INPUT"){
                    ele.attr("name",tempName);
                    if(type.toLowerCase()=="radio"){
                        if(tempString=="series_part_showSymbol" || tempString=="series_part_label_show" || tempString=="series_part_markPoint_data_0_label_show" || tempString=="series_part_markPoint_data_1_label_show" || tempString=="series_part_markPoint_data_2_label_show" ||tempString=="series_part_markLine_data_0_label_show" ||tempString=="series_part_markLine_data_1_label_show" ||tempString=="series_part_markLine_data_2_label_show"){
                            ele.attr("lay-filter",tempName);
                            form.on('radio('+tempName+')', function(data){
                                if(data.value=='false'){
                                    $("#"+data.elem.name+"_div").hide();
                                }else{
                                    $("#"+data.elem.name+"_div").show();
                                }
                            });
                        }
                    }else if(type.toLowerCase()=="checkbox"){
                        if(tempString=="series_part_markPoint_data_0_type" || tempString=="series_part_markPoint_data_1_type" ||tempString=="series_part_markPoint_data_2_type" ||tempString=="series_part_markLine_data_0_type" ||tempString=="series_part_markLine_data_1_type" ||tempString=="series_part_markLine_data_2_type"){
                            ele.attr("lay-filter",tempName);
                            form.on('checkbox('+tempName+')', function(data){
                                if(($("input[type='checkbox'][name="+data.elem.name+"]").is(':checked'))){
                                    $("#"+data.elem.name+"_div").show();
                                }else{
                                    $("#"+data.elem.name+"_div").hide();
                                }
                            });
                        }
                    }
                }else if(tagName.toUpperCase()=="DIV"){
                    ele.attr("id",tempName);
                }else if(tagName.toUpperCase()=="SELECT"){
                    ele.attr("name",tempName);
                }
            });

            /*---添加选色器----*/
            var colorpicker = layui.colorpicker,colorpickerDefaultColor = '#1c97f5';
            $(".dynamic-series-chooser").each(function(i,e){
                var ele = $(e),tempName = t_prefix + ele.attr("dynamicSeries");
                ele.attr("name",tempName);
                colorpicker.render({
                    tmpTarget:tempName
                    ,elem: '#'+tempName+'_choose'
                    ,color: $($('input[name='+this.tmpTarget+']')[0]).val() || colorpickerDefaultColor
                    ,done: function(color){
                        $($('input[name='+this.tmpTarget+']')[0]).val(color);
                    }
                });
            })
        });
    }
}
